package com.alter.model;

import java.sql.Clob;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 改model 将个人文章和站点文章都柔和到了 一起。
 * 
 * @author A_Alter
 */
@Entity
@Table(name = "AF_ARTICLE")
public class AfArticle extends EnabledEntity {

    private static final long serialVersionUID = 1L;

    @Column(nullable = false)
    private String title;

    @Column(nullable = false)
    private Clob content;
    
    /** 文章简讯 */
    @Column(length = 2000)
    private String brief;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "type_aid")
    private AfPersonalArticleType type;

    /**
     * 系统所属分类。
     */
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "bar_aid", nullable = true)
    private SeNavBar bar;

    /**
     * 文章會涉及到分页查询，使用EAGER 不太合适。
     */
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "article_tag", joinColumns = { @JoinColumn(table = "AF_ARTICLE", referencedColumnName = "aid") }, inverseJoinColumns = { @JoinColumn(table = "AF_TAG", referencedColumnName = "aid") })
    private List<AfTag> tags = new ArrayList<AfTag>(5);

    public String getTitle() {
	return title;
    }

    public void setTitle(String title) {
	this.title = title;
    }

    public Clob getContent() {
	return content;
    }

    public void setContent(Clob content) {
	this.content = content;
    }

    public List<AfTag> getTags() {
	return tags;
    }

    public void setTags(List<AfTag> tags) {
	this.tags = tags;
    }

    public SeNavBar getBar() {
	return bar;
    }

    public void setBar(SeNavBar bar) {
	this.bar = bar;
    }

    public AfPersonalArticleType getType() {
	return type;
    }

    public void setType(AfPersonalArticleType type) {
	this.type = type;
    }

    public String getBrief() {
        return brief;
    }

    public void setBrief(String brief) {
        this.brief = brief;
    }

   
    

}
